﻿<Window x:Class="FlowSequencer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
        xmlns:converter="clr-namespace:FlowSequencer.Converters"
        Title="Sequencer" Height="438" Width="749" Icon="machine.ico">

    <Window.Resources>
        <converter:ListIntToString x:Key="listIntToString" />
        <BooleanToVisibilityConverter x:Key="b2v" />
    </Window.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" MinHeight="120px"/>
            <RowDefinition Height="50px"/>
            <RowDefinition Height="2*"/>
            <RowDefinition Height="50px"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="100px" />
                    <ColumnDefinition Width="3*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0">
                    <Label Margin="5,0,-5,0">Ilość zadań:</Label>
                    <TextBox Margin="15,2,10,2" x:Name="numberTasksTextBox"  Text="{Binding NumberOfTasks, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="numberTasksTextBox_TextChanged"/>
                    <!--<Label Grid.Column="0" Margin="5,0,-5,0">Ilość maszyn:</Label>-->
                    <!--<RadioButton Name="Machine2xRadioButton" GroupName="MachineNumberGroup" Checked="Machine2xRadioButton_Checked_1" IsChecked="{Binding IsTwoMachineMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="17,0,10,0">2x maszyny</RadioButton>
                    <RadioButton Name="Machine3xRadioButton" GroupName="MachineNumberGroup" Checked="Machine3xRadioButton_Checked_1" Margin="16,0,10,0">3x maszyny</RadioButton>-->
                </StackPanel>

                <Grid Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Margin="0,0,142,0">
                        <TextBlock Text=""/>
                        <TextBlock Text=""/>
                        <TextBlock Text="Period"/>
                        <TextBlock Text=""/>
                        <TextBlock Text="Processing time"/>
                        <TextBlock Text=""/>
                        <TextBlock Text="Relative deadline"/>

                    </StackPanel>
                <ListView ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible" Grid.ColumnSpan="2" Margin="141,0,0,0">
             
                    <DataGrid Name="processInputGrid" Margin="5" AutoGenerateColumns="False" ItemsSource="{Binding Lines, Mode=TwoWay, UpdateSourceTrigger=Explicit}">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn>
                                <DataGridTemplateColumn.HeaderTemplate>
                                    <DataTemplate>
                                        <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Headers}">
                                            <ItemsControl.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Orientation="Horizontal"/>
                                                </ItemsPanelTemplate>
                                            </ItemsControl.ItemsPanel>
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <TextBlock Margin="2" Width="{Binding Width}" Foreground="{Binding Color}" Text="{Binding Data}"/>
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                        </ItemsControl>
                                    </DataTemplate>
                                </DataGridTemplateColumn.HeaderTemplate>
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <ItemsControl ItemsSource="{Binding ColumnsData}">
                                            <ItemsControl.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Orientation="Horizontal"/>
                                                </ItemsPanelTemplate>
                                            </ItemsControl.ItemsPanel>
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <TextBox Margin="2" Width="{Binding Width}" Text="{Binding Data}"/>
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                        </ItemsControl>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </ListView>
                </Grid>
            </Grid>
        </StackPanel>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="70px"/>
                <ColumnDefinition Width="50px"/>
                <ColumnDefinition Width="70px"/>
                <ColumnDefinition Width="100px"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="Minor Cycle:"/>
            <TextBlock Grid.Column="1" x:Name="DownTime"  Text="{Binding MinorCycle}" />
            <TextBlock Grid.Column="2" Text="Major Cycle:"/>
            <TextBlock Grid.Column="3" x:Name="DownTimeName"  Text="{Binding MajorCycle}" />
            
        </Grid>
        <ListView Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible">
            <Label Content="Wykres gantaa:"/>
            <Grid Name="ganttView">
            </Grid>
        </ListView>
        <Button Grid.Row="3" Name="startProcessingButton" Content="Oblicz" Click="startProcessingButton_Click_1"/>
    </Grid>
</Window>
